package com.thread_pool.dynamic_tp.ctroller;

import lombok.extern.slf4j.Slf4j;
import org.dromara.dynamictp.core.DtpRegistry;
import org.dromara.dynamictp.core.thread.DtpExecutor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @author linjy on 2023/6/28
 */
@RestController
@RequestMapping("/confirm")
//@Slf4j(topic = "c.TestController")
@Slf4j
public class TestController {
    @Resource
    private ThreadPoolExecutor dtpExecutor1;

    @GetMapping("test")
    public void exec() {
        dtpExecutor1.execute(() -> log.info("test"));
    }

    @GetMapping("test2")
    public void exec2() {
        DtpExecutor dtpExecutor = DtpRegistry.getDtpExecutor("dtpExecutor1");
        dtpExecutor.execute(() -> log.info("test2"));
    }

}
